package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Creared with IntelliJ IDEA.
 * Description:简单的翻译逻辑
 * User:yxd
 * Date:2022-04-11
 * Time:17:31
 */
public class UDPDictSever extends UDPEchoServer{
    private Map<String,String> map = new HashMap<>();
    public UDPDictSever(int port) throws SocketException {
        super(port);
        map.put("dog","二狗");
        map.put("pig","小猪猪");
        map.put("cat","猫咪");
    }

    //此时就只需要改这个重写的子方法就好了
    @Override
    public String prcoess(String request) {
        return map.getOrDefault(request,"字典中不包含该单词");
    }

    public static void main(String[] args) throws IOException {
        UDPDictSever dictSever = new UDPDictSever(9090);
        dictSever.start();
    }
}
